package com.example.page.data.remote.model

import com.example.page.data.model.Quotes
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
 * API 返回的 Quotes Data 类
 * @property id 引用的唯一标识符
 * @property quoteAuthor 引用的作者
 * @property quoteGenre 引用的类型或者流派
 * @property quoteText 引用的文本内容
 * @property v 版本信息
 *
 * App -> API -> API Model Class(JSON 中 List<QuotesData> 中 QuotesData 的定义)
 */
@Serializable
data class QuotesData(
    @SerialName("_id")
    val id: String = "",
    @SerialName("quoteAuthor")
    val quoteAuthor: String = "",
    @SerialName("quoteGenre")
    val quoteGenre: String = "",
    @SerialName("quoteText")
    val quoteText: String = "",
    @SerialName("__v")
    val v: Int = 0
)

/**
 * 扩展函数, 将 API Model Class -> Model Class
 * @receiver QuotesData
 * @param currentPage 当前页数
 * @return Quotes Model Class
 */
fun QuotesData.toQuotes(currentPage: Int): Quotes {
    return Quotes(
        id = id,
        quoteAuthor = quoteAuthor,
        quoteGenre = quoteGenre,
        quoteText = quoteText,
        currentPage = currentPage
    )
}